//
//  APAboutViewController.m
//  AqualPolo
//
//  Created by dong on 2024/5/9.
//

#import "APAboutViewController.h"
#import "APTitleControl.h"
#import "APWebViewController.h"

@interface APAboutViewController ()
@property (nonatomic, strong) UIImageView *logoImageView;

@end

@implementation APAboutViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self loadNaviBar];
    self.naviBar.titleLabel.text = @"About";
    [self initUI];
}

- (void)termofUseDidClick{
    APWebViewController *webVC = [[APWebViewController alloc] init];
    webVC.urlString = Term_Use__URL;
    webVC.titleString = Term_of_Use_title;
    [self presentViewController:webVC animated:true completion:nil];
}

- (void)privacyPolicyDidClick{
    APWebViewController *webVC = [[APWebViewController alloc] init];
    webVC.urlString = Privacy_Policy_URL;
    webVC.titleString = Privacy_Policy_title;
    [self presentViewController:webVC animated:true completion:nil];
}


- (void)initUI{
    _logoImageView = [[UIImageView alloc] init];
    _logoImageView.image = [UIImage imageNamed:@"launch_icon"];
    [self.view addSubview:_logoImageView];
    [_logoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.naviBar.mas_bottom).offset(16);
        make.centerX.equalTo(self.view);
        make.size.mas_equalTo(CGSizeMake(88, 88));
    }];
    UILabel *nameLabel = [[UILabel alloc] init];
    nameLabel.textColor = [UIColor whiteColor];
    nameLabel.font = [LYFont fontWithSize:22 fontName:LYFontNamepfb];
    nameLabel.textAlignment = NSTextAlignmentCenter;
    nameLabel.text = @"AquaPolo";
    [self.view addSubview:nameLabel];
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_logoImageView.mas_bottom).offset(12);
        make.left.right.equalTo(self.view);
    }];
    
    APTitleControl *versionControl = [[APTitleControl alloc] init];
    versionControl.titleLabel.text = @"Version";
    NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
    NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
    versionControl.contentLabel.text = app_Version;
    versionControl.contentLabel.textColor = LYRGBColor(158, 253, 223);
    versionControl.contentLabel.font = [LYFont fontWithSize:12 fontName:LYFontNamepfb];
    [self.view addSubview:versionControl];
    [versionControl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(nameLabel.mas_bottom).offset(24);
        make.left.equalTo(self.view).offset(32);
        make.right.equalTo(self.view).offset(-32);
        make.height.mas_equalTo(44);
    }];

    APTitleControl *termControl = [[APTitleControl alloc] init];
    [termControl addTarget:self action:@selector(termofUseDidClick) forControlEvents:UIControlEventTouchUpInside];
    termControl.titleLabel.text = @"Terms and Conditons";
    [self.view addSubview:termControl];
    [termControl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(versionControl.mas_bottom).offset(24);
        make.left.equalTo(self.view).offset(32);
        make.right.equalTo(self.view).offset(-32);
        make.height.mas_equalTo(44);
    }];
    
    APTitleControl *policyControl = [[APTitleControl alloc] init];
    [policyControl addTarget:self action:@selector(privacyPolicyDidClick) forControlEvents:UIControlEventTouchUpInside];
    policyControl.titleLabel.text = @"Privacy Policy";
    [self.view addSubview:policyControl];
    [policyControl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(termControl.mas_bottom).offset(24);
        make.left.equalTo(self.view).offset(32);
        make.right.equalTo(self.view).offset(-32);
        make.height.mas_equalTo(44);
    }];
}

@end
